package com.itheima.mapper;

import com.itheima.pojo.Article;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;

import java.util.List;

/**
 * @Author 27435
 * @Date 2024/12/20下午10:40
 * @Version 1.0
 */

@Mapper
public interface ArticleMapper {


    /**
     * 新增文章
     * @param article 文章对象
     */
    @Insert("insert into article(title, content, cover_img, state, category_id, create_user, create_time, update_time) " +
            "values (#{title}, #{content}, #{coverImg}, #{state}, #{categoryId}, #{createUser}, #{createTime}, #{updateTime})")
    void add(Article article);

    /**
     * 查询文章列表
     * @param userId 用户id
     * @param categoryId 分类id
     * @param state 发布状态
     * @return
     */
    List<Article> list(Integer userId, Integer categoryId, String state);
}
